home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 732 / pstools / resetadobe / resetadobe.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  2KB  |  94 lines

  1.  
  2. /*
  3.   Name:               resetadobe.c
  4.   Processor:          Amiga 68000
  5.   Compiler directive: lc -L xxx.c
  6.   Creation Date:      11 May 92
  7.   Version:            1.00
  8.   Author:             I Parker & D Spencer
  9.  
  10.   Description Changes character spacing in afm files after creation by 
  11.               pfm2afm
  12. */
  13.  
  14. #include <stdio.h>
  15. #include <string.h>
  16.  
  17. #define outfile "corrected.afm" /* output file name preset */
  18.  
  19. FILE *ifp, *ofp, *fopen();
  20.  
  21. main (argc, argv)
  22. int argc;
  23. char *argv[];
  24. {
  25. char inline[100]; /* input line buffer */
  26. int index;
  27.     if(argc == 1)
  28.     {
  29.     printf("\033[33mresetadobe by I Parker & D Spencer V1.00\n");
  30.              /* \033[33m = prt blue */
  31.     printf("Usage resetadobe xxx.afm increase\033[31m\n");
  32.              /* \033[31m = reset */
  33.     }
  34.     if(argc == 2)
  35.     printf("\033[4msize increase missing\033[0m\n");
  36.     /* \033[4m Underline */
  37.  
  38.     if(argc >= 3)
  39.     {
  40.     if((ifp = fopen(argv[1],"r"))==NULL) {
  41.     fprintf(stderr, "Error : Cannot open input file %s\n", strupr(argv[1]));
  42.         exit(-1);
  43.         }
  44.     if((ofp = fopen(outfile, "wb"))==NULL) {
  45.     fprintf(stderr, "Error : Unable to open output file %s\n",outfile);
  46.     exit(1);
  47.     }
  48.     printf("Converting adobe font metrics spacing by %s\n",argv[2]);    
  49.     while(fgets(inline,100,ifp)!=NULL)
  50.         {
  51.          char outline[100];
  52.          int op;
  53.          int total,modification;
  54.  
  55.          modification=atoi(argv[2]);
  56.      index = 0;
  57.          op = 0;
  58.  
  59.          for (index=0; inline[index] /*!='\n'*/ && inline[index]!='W';index++)
  60.              outline[op++]=inline[index];
  61.  
  62.          if ((outline[op++]=inline[index++])=='W')
  63.          {
  64.            if ((outline[op++]=inline[index++])=='X')
  65.            {
  66.              total=0;
  67.  
  68.              while (inline[index]<'0' || inline[index]>'9')
  69.                outline[op++]=inline[index++];
  70.  
  71.              /* now op corresponds to the first digit in inline[]. */
  72.  
  73.              while (inline[index]>='0' && inline[index]<='9')
  74.                total = total*10+inline[index++]-'0';
  75.  
  76.              total = total+modification;         /* comment! */
  77.  
  78.              op += sprintf(outline+op,"%d",total);
  79.  
  80.            }
  81.            while (outline[op++]=inline[index++]);
  82.  
  83.          }
  84.  
  85.          index=0;
  86.          while(outline[index] != '\0')
  87.            putc((outline[index++]),ofp);
  88.  
  89.     } /* end of while --fgets-- */
  90. }
  91.     fclose(ifp);
  92.     fclose(ofp);
  93.  
  94. }